package com.unionftech.crm_android.adapter

import android.text.TextUtils
import android.widget.ImageView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.unionftech.baselibrary.glide.loadImage
import com.unionftech.crm_android.R

class IntroductionPagerAdapter(list: MutableList<IntroductionInfo>) :
    BaseQuickAdapter<IntroductionInfo, BaseViewHolder>(
        R.layout.layout_introduction_page_view,
        list
    ) {
    override fun convert(holder: BaseViewHolder, item: IntroductionInfo) {
        if (TextUtils.isEmpty(item.imageUrl)) {
            holder.setImageResource(R.id.iv_introduction_bg, item.imgRes)
        } else {
            holder.getView<ImageView>(R.id.iv_introduction_bg)
                .loadImage(
                    item.imageUrl,
                    placeholderResId = item.imgRes
                )
        }
    }
}

data class IntroductionInfo(val imgRes: Int, var imageUrl: String?)